package com.zr.action;

import java.io.IOException;
import java.io.PrintWriter;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts2.interceptor.ServletRequestAware;
import org.apache.struts2.interceptor.ServletResponseAware;
import org.hibernate.Session;

import com.opensymphony.xwork2.ActionSupport;
import com.zr.service.CargostatusserviceCH;
import com.zr.service.UpdateCargostatusserviceCH;

import net.sf.json.JSONObject;

public class UpdateCargostatusActionCH extends ActionSupport implements ServletRequestAware,ServletResponseAware{
	private HttpServletRequest req;
	private HttpServletResponse resp;
	private int csId; 
	private String csCurrentLocation;
	private String csNextLocation;
	private String csCurrentDate;
	public int getCsId() {
		return csId;
	}
	public void setCsId(int csId) {
		this.csId = csId;
	}
	public String getCsCurrentLocation() {
		return csCurrentLocation;
	}
	public void setCsCurrentLocation(String csCurrentLocation) {
		this.csCurrentLocation = csCurrentLocation;
	}
	public String getCsNextLocation() {
		return csNextLocation;
	}
	public void setCsNextLocation(String csNextLocation) {
		this.csNextLocation = csNextLocation;
	}
	public String getCsCurrentDate() {
		return csCurrentDate;
	}
	public void setCsCurrentDate(String csCurrentDate) {
		this.csCurrentDate = csCurrentDate;
	}



			//属性注入
			@Resource
			private  UpdateCargostatusserviceCH ucsc;
	/**
	 * 更新货物维护表信息
	 * */
	public void updateCargostatu(){
		resp.setCharacterEncoding("utf8");
//		Calendar now = Calendar.getInstance();     
//        Date d = new Date();  
//        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");  
//        String csCurrentDate = sdf.format(d); 

 System.out.println(csCurrentLocation);
 System.out.println(csNextLocation);
		try {
		 PrintWriter pt=resp.getWriter();
		 boolean flag=ucsc.updateCargotatus(csId, csCurrentLocation, csNextLocation);		 
			if(flag){			 
				  pt.write("1");
			}
			
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	
	}
	
	
	
	@Override
	public void setServletResponse(HttpServletResponse arg0) {
		// TODO Auto-generated method stub
		this.resp=arg0;
	}
	@Override
	public void setServletRequest(HttpServletRequest arg0) {
		// TODO Auto-generated method stub
		this.req=arg0;
		
	}

}
